@extends('admin.layout')
@section('title','首页图片')
@section('body')
    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
        <legend>首页图片 <a href="{{url('config/banner_create')}}" style="margin-left: 30px" class="btn btn-primary">添加图片</a>  </legend>
    </fieldset>
    <table class="layui-table " >
        <colgroup>

        </colgroup>
        <thead>
        <tr>
            <th>图片</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        @foreach($banner as $value)
            <tr>
                <td><img style="width: 300px;height: 200px;"   src="{{url($value->my_img->pic_path)}}" alt=""></td>
                <td id="content{{$value->banner_id}}" hidden>{{$value->detail}}</td>
                <td >
                    <button class="btn-primary btn " onclick="content('{{$value->banner_id}}')">查看详情</button>
                    <button class="btn-danger btn  " onclick="del('{{$value->banner_id}}')">删除</button>
                </td>
            </tr>
        @endforeach
        </tbody>
    </table>

    <div id="content" style="display: none"></div>
@endsection
@section('js')

    <script>
        @if(Session::has('message'))
             layer.msg("{{Session::get("message")}}");
        {{Session::forget('message')}}
        @endif


        function content(id){
            var html =$("#content"+id).html();
            document.getElementById('content').innerHTML=html;
            layer.open({
                title:"图文详情",
                offset:'20px',
                anim:'5',
                area:['1200px','800px'],
                resize:true,
                moveOut:true,
                type:1,
                content:$("#content"),
            })
        }

        function del(id) {
            layer.open({
                title:"提示",
                content:'确定删除吗？！<form id="down" method="post" action=""><input type="hidden" name="banner_id" value="'+id+'"><input type="hidden" name="type" value="del">{{csrf_field()}}</form>',
                yes:function () {
                    $("#down").submit();
                }
            })
        }

    </script>

@endsection

